<!DOCTYPE html>
<html lang=zh-CN>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="google-site-verification" content="xBT4GhYoi5qRD5tr338pgPM5OWHHIDR6mNg1a3euekI" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta property="og:description" content="samuel-24276的博客">
    <meta property="og:type" content="website">
    <meta name="description" content="samuel-24276的博客">
    <meta name="keyword"  content="aircloud">
    <link rel="shortcut icon" href="/myblog/img/favicon.ico">

    <title>
        
        我的收藏 - samuel-24276的博客 | samuel-24276&#39;s Blog
        
    </title>

    <!-- Custom CSS -->
    
<link rel="stylesheet" href="/myblog/css/aircloud.css">

    
<link rel="stylesheet" href="/myblog/css/gitment.css">

    <!--<link rel="stylesheet" href="https://imsun.github.io/gitment/style/default.css">-->
    <link href="//at.alicdn.com/t/font_620856_28hi1hpxx24.css" rel="stylesheet" type="text/css">
    <!-- ga & ba script hoook -->
    <script></script>
<meta name="generator" content="Hexo 7.1.1"></head>

<body>

<div class="site-nav-toggle" id="site-nav-toggle">
    <button>
        <span class="btn-bar"></span>
        <span class="btn-bar"></span>
        <span class="btn-bar"></span>
    </button>
</div>

<div class="index-about">
    <i> Like what you do, do what you like </i>
</div>

<div class="index-container">
    
    <div class="index-left">
        
<div class="nav" id="nav">
    <div class="avatar-name">
        <div class="avatar ">
            <img src="/myblog/img/avatar.jpg" />
        </div>
        <div class="name">
            <i>samuel-24276</i>
        </div>
    </div>
    <div class="contents" id="nav-content">
        <ul>
            <li >
                <a href="/myblog/">
                    <i class="iconfont icon-shouye1"></i>
                    <span>主页</span>
                </a>
            </li>
            <li >
                <a href="/myblog/tags">
                    <i class="iconfont icon-biaoqian1"></i>
                    <span>标签</span>
                </a>
            </li>
            <li >
                <a href="/myblog/archives">
                    <i class="iconfont icon-guidang2"></i>
                    <span>存档</span>
                </a>
            </li>
            <li  class=active >
                <a href="/myblog/collect/">
                    <i class="iconfont icon-shoucang1"></i>
                    <span>收藏</span>
                </a>
            </li>
            <li >
                <a href="/myblog/about/">
                    <i class="iconfont icon-guanyu2"></i>
                    <span>关于</span>
                </a>
            </li>
            
            <li>
                <a id="search">
                    <i class="iconfont icon-sousuo1"></i>
                    <span>搜索</span>
                </a>
            </li>
            
        </ul>
    </div>
    
</div>


<div class="search-field" id="search-field">
    <div class="search-bg" id="search-bg"></div>
    <div class="search-container">
        <div class="search-input">
            <span id="esc-search"> <i class="icon-fanhui iconfont"></i></span>
            <input id="search-input"/>
            <span id="begin-search">搜索</span>
        </div>
        <div class="search-result-container" id="search-result-container">

        </div>
    </div>
</div>

        <div class="index-about-mobile">
            <i> Like what you do, do what you like </i>
        </div>
    </div>
    
    <div class="index-middle">
        <!-- Main Content -->
        
<div class="post-content no-indent">
  <h1 id="不需要moc机制的Qt"><a href="#不需要moc机制的Qt" class="headerlink" title="不需要moc机制的Qt"></a>不需要moc机制的Qt</h1><blockquote>
<p><a target="_blank" rel="noopener" href="https://woboq.com/blog/verdigris-qt-without-moc.html">Verdigris: Qt without moc</a></p>
</blockquote>
<p>Verdigris(碱式碳酸铜) 是一个仅标头库，可以是 与Qt一起使用。它使用宏来创建与Qt自己的二进制兼容的QMetaObject，无需 moc。 换句话说，您可以在Qt或QML应用程序中使用Verdigris宏，而不是某些Qt 宏，然后您不需要运行 MOC。</p>
<h1 id="Qt元对象编译器与C-反射机制"><a href="#Qt元对象编译器与C-反射机制" class="headerlink" title="Qt元对象编译器与C++反射机制"></a>Qt元对象编译器与C++反射机制</h1><blockquote>
<p><a target="_blank" rel="noopener" href="https://woboq.com/blog/reflection-in-cpp-and-qt-moc.html">Can Qt’s moc be replaced by C++ reflection?</a></p>
</blockquote>
<p>N3951提案包含了新的C++调整，用来添加编译器内省机制，它赋予了<code>typedef</code>和<code>typename</code>新的含义，并且可以像这样工作( <a target="_blank" rel="noopener" href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3951.pdf">N3951: C++ type reflection via variadic template expansion</a>)：</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* Given a simple class */</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">SomeClass</span> &#123; </span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line">  <span class="function"><span class="type">int</span> <span class="title">foo</span><span class="params">()</span></span>;</span><br><span class="line">  <span class="function"><span class="type">void</span> <span class="title">bar</span><span class="params">(<span class="type">int</span> x)</span></span>;</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="keyword">if</span> 0</span></span><br><span class="line"><span class="comment">/* The new typename&lt;&gt;... and typedef&lt;&gt;... &#x27;operators&#x27; : */</span></span><br><span class="line">  vector&lt;string&gt; names = &#123; <span class="keyword">typename</span>&lt;SomeClass&gt;... &#125; ;</span><br><span class="line">  <span class="keyword">auto</span> members = std::<span class="built_in">make_tuple</span>(<span class="keyword">typedef</span>&lt;SomeClass&gt;...) ;</span><br><span class="line"><span class="meta">#<span class="keyword">else</span></span></span><br><span class="line"><span class="comment">/* Would be expanded to something equivalent to: */</span></span><br><span class="line">  vector&lt;string&gt; names =  &#123; <span class="string">&quot;SomeClass&quot;</span>,  <span class="string">&quot;foo&quot;</span>, <span class="string">&quot;bar&quot;</span> &#125;;</span><br><span class="line">  <span class="keyword">auto</span> members = std::<span class="built_in">make_tuple</span>(<span class="built_in">static_cast</span>&lt;SomeClass*&gt;(<span class="literal">nullptr</span>), </span><br><span class="line">                               &amp;SomeClass::foo, &amp;SomeClass::bar);</span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br></pre></td></tr></table></figure>

<p>我一直在设法使用这些提案重新实现大多数 moc 功能，例如信号、插槽和属性，而无需 moc。当然，由于编译器显然还不支持该提案，因此我一直在原型中手动扩展 typedef和typename。</p>
<p>该代码做了很多模板技巧来在编译时处理字符串和数组，并生成一个QMetaObject甚至二进制兼容的moc：<br><a target="_blank" rel="noopener" href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3814.html">如何使用内省和反射机制扩展C++</a></p>
<p><a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Trait_(computer_programming)">C++ traits萃取介绍</a></p>
<p><a target="_blank" rel="noopener" href="https://woboq.com/blog/reflection-in-cpp-and-qt-moc/code/metaobjectbuilder.cc.html">扩展typename和typedef实现moc功能的代码</a></p>
<h1 id="Verdigris-实现中使用的两个C-技巧"><a href="#Verdigris-实现中使用的两个C-技巧" class="headerlink" title="Verdigris 实现中使用的两个C++技巧"></a>Verdigris 实现中使用的两个C++技巧</h1><blockquote>
<p><a target="_blank" rel="noopener" href="https://woboq.com/blog/verdigris-implementation-tricks.html">Two C++ tricks used in Verdigris implementation</a></p>
</blockquote>

  <div id="comment-container">
  </div>
  <div id="lv-container">
  </div>
</div>

    </div>
</div>


<footer class="footer">
    <ul class="list-inline text-center">
        
        

        

        

        
        <li>
            <a target="_blank"  href="https://github.com/samuel-24276">
                            <span class="fa-stack fa-lg">
                                <i class="iconfont icon-github"></i>
                            </span>
            </a>
        </li>
        

        

    </ul>
    
    <p>
        <span>/</span>
        
        <span><a target="_blank" rel="noopener" href="https://github.com/samuel-24276">samuel-24276&#39;s Page</a></span>
        <span>/</span>
        
        <span><a target="_blank" rel="noopener" href="https://beian.miit.gov.cn/">北京-未备案</a></span>
        <span>/</span>
        
        <span><a href="#">返回顶部</a></span>
        <span>/</span>
        
    </p>
    
    <p>
        <span id="busuanzi_container_site_pv">
            <span id="busuanzi_value_site_pv"></span>PV
        </span>
        <span id="busuanzi_container_site_uv">
            <span id="busuanzi_value_site_uv"></span>UV
        </span>
        Created By <a target="_blank" rel="noopener" href="https://hexo.io/">Hexo</a>  Theme <a target="_blank" rel="noopener" href="https://github.com/aircloud/hexo-theme-aircloud">AirCloud</a></p>
</footer>




</body>

<script>
    // We expose some of the variables needed by the front end
    window.hexo_search_path = "search.json"
    window.hexo_root = "/myblog/"
    window.isPost = false
</script>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>

<script src="/myblog/js/index.js"></script>

<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>






</html>
